<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Title</title>
</head>
<body>
<input type="text" id="i1">
<input type="text" id="i2">
<input type="button" value="加" onclick="f()">
<input type="button" value="减" onclick="f()">
<input type="button" value="乘" onclick="f()">
<input type="button" value="除" onclick="f()">
<div></div>
<script>
    function f() {
        let a=document.querySelector("#i1")
        let b=document.querySelector("#i2")
        let g=document.querySelector("div")
    if (isNaN(a.value)){
        b.innerText="输出错误"
    }else{
        g.innerText = a.value * 1 + b.value * 1
       if(isNaN(a.value)){
           b.innerText="输出错误"
       }else{
           g.innerText = a.value * 1 - b.value * 1
           if (isNaN(a.value)){
               b.innerText="输出错误"
           }else{
               g.innerText = a.value* b.value
               if (isNaN(a.value)){
                   b.innerText="输出错误"
               }else{
                   g.innerText = a.value*1 / b.value*1
               }
           }
       }
    }
    }

</script>
</body>
</html>